package cn.webrx.chat;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Server {
    public static void main(String[] args) {

        try {
            //Socket套接字(TCP/IP)  List<Socket>
            ServerSocket server = new ServerSocket(6666);
            Socket s = server.accept();
            PrintWriter out = new PrintWriter(s.getOutputStream());
            BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
            while (true) {
                String sss = br.readLine();//
                System.out.println(sss);
                out.write((new Scanner(System.in)).nextLine()+"\r\n");
                out.flush();
            }
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}
